public class Caesar {

	final String ALFABET = "abcdefghijklmnopqrstuvwxyz";

	String ENCRYPT = null;
	int KEY = -1;

	public Caesar(String e) {
		this.ENCRYPT = e;
	}

	public Caesar(String e, int k) {
		this.ENCRYPT = e;
		this.KEY = k;
	}

	public void setKey(int k) {
		this.KEY = k;
	}

	public void setEncrypt(String s) {
		this.ENCRYPT = s;
	}

	public String encrypt() {
		String res = "";
		if (ENCRYPT == null || ENCRYPT.length() == 0) {
			return null;
		}

		for (int i = 0; i < ENCRYPT.length(); i++) {
			res += ALFABET.charAt(Methods.mod(
					(Methods.charToNum(ENCRYPT.charAt(i)) + KEY), 26));
		}
		return res;
	}

	public String decrypt() {
		String res = "";
		if (ENCRYPT == null || ENCRYPT.length() == 0) {
			return null;
		}

		for (int i = 0; i < ENCRYPT.length(); i++) {
			res += ALFABET.charAt(Methods.mod(
					(Methods.charToNum(ENCRYPT.charAt(i)) - KEY), 26));
		}
		return res;
	}

}
